package priv.mill.controller;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import priv.mill.dao.model.UserT;
import priv.mill.server.IUserService;
/**
 * 1. @Controller相当于Component注解,让Spring自动扫描进去
 * 2. 使用 @RequestMapping 注解来映射请求的 URL
 * 3. 返回值会通过视图解析器解析为实际的物理视图, 对于 InternalResourceViewResolver 视图解析器, 会做如下的解析:
 * 通过 prefix + returnVal + 后缀 这样的方式得到实际的物理视图, 然会做转发操作
 * 
 * /WEB-INF/views/success.jsp
 * 
 */
@Controller
@RequestMapping("/user")
public class UserController {
	@Resource
	private IUserService userService;
	
	@RequestMapping("/showUser")
	public String toIndex(HttpServletRequest request,Model model){
		int userId = Integer.parseInt(request.getParameter("id"));
		UserT user = this.userService.getUserById(userId);
		model.addAttribute("user", user);
		return "user";
	}
}
